package com.zyf.springcloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyf.springcloud.dao.RolePermissionDao;
import com.zyf.springcloud.model.RolePermission;
import com.zyf.springcloud.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service

public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionDao, RolePermission> implements RolePermissionService {

    @Autowired
    RolePermissionDao rolePermissionDao;
    public Object getAll(){
        return rolePermissionDao.selectList(null);
    }
    public List selectRoleIdByPermissionId(int PermissionId){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("permission_id",PermissionId);
        List<RolePermission> list = rolePermissionDao.selectList(queryWrapper);
        List<Integer> list1=new ArrayList<>();
        for (RolePermission item:list){
            list1.add(item.getRoleId());
        }
        return list1;
    }
}
